package com.xique.door.listener;

import com.xique.door.bean.domain.PermissionGroup;
import com.xique.door.event.BuildPermissionGroupCreateEvent;
import com.xique.door.service.IPermissionGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author shd
 * @create 2021/9/10 9:36
 */
@Component
public class BuildPermissionGroupCreateListener implements ApplicationListener<BuildPermissionGroupCreateEvent> {

    @Autowired
    private IPermissionGroupService permissionGroupService;

    @Override
    @Async
    public void onApplicationEvent(BuildPermissionGroupCreateEvent event) {
        PermissionGroup group = new PermissionGroup();
        group.setParkId(event.getParkId());
        group.setForeignId(event.getForeignId());
        group.setForeignType(event.getForeignType());
        group.setGroupName(event.getGroupName());
        group.setStatus(event.getStatus());

        permissionGroupService.insertPermissionGroup(group);
    }
}
